package com.cash.app.net

sealed class NetResult<out T> {
    data class Success<out T>(val data: T?) : NetResult<T>()
    data class Error(val code: Int, val message: String) : NetResult<Nothing>()

    // val e: Throwable
    data class Exception(val code: Int, val message: String) : NetResult<Nothing>()
}

//fun <T> NetResult<T>.onSuccess(block: (T) -> Unit): NetResult<T> {
//    if (this is NetResult.Success) block(data)
//    return this
//}
//
//fun <T> NetResult<T>.onError(block: (code: Int, message: String) -> Unit): NetResult<T> {
//    if (this is NetResult.Error) block(code, message)
//    return this
//}
//
//fun <T> NetResult<T>.onException(block: (message: String) -> Unit): NetResult<T> {
//    if (this is NetResult.Exception) block(message)
//    return this
//}